﻿<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\Model\Message;
use app\admin\Model\Admin as Adm;
use app\admin\Model\Use1;
use think\Db;
use app\admin\validate\Stu as qbc;

class Admin extends Common
{
	//真好
	public function list(){
		
		$list = Adm::with('use1')->paginate(4);
		$page = $list->render();
	     //halt($list);
		
		return $this->fetch('list',['list'=>$list,'page'=>$page]);
	}
	public function add(){
		$adm = new Adm();
			
		if(input("?param.sub")){
			
			
			$result = $adm->add();
			if($result){
				$this->success("添加成功","admin/list");
			}else{
				$this->error("添加失败");
			}
		}else{
			$list = Use1::all();
			
			
			return $this->fetch("add",['list'=>$list]);
		}
	}
	public function update(){
		$adm = new Adm();
		
		if(input("?param.sub")){
			
			$result = $adm->upd();
			
			if($result){
				$this->success("修改成功","admin/list");
			}else{
				$this->error("修改失败");
			}
		}else{
			$id = input('param.a_id');
			
			$list = Use1::all();
			$list1 = Adm::get($id);
			
			return $this->fetch("update",['list'=>$list,'list1'=>$list1]);
		}
	}

}
?>